#!/usr/bin/env python3

# 运算符
## 按位预算
a = 60      # 60 = 0011 1100
b = 13      # 13 = 0000 1101
c = 0

# 按位与运算符
c = a & b;  # 12 = 0000 1100    按位对比全是1的，结果为1，其余均为0
print("Line 1 - Value of c is ", c)

# 按位或运算符
c = a | b;  # 61 = 0011 1101    按位对比有一个是1的或全是1的，结果为1，其余为0
print("Line 2 - Value of c is ", c)

# 按位异或运算符
c = a ^ b;  # 49 = 0011 0001    按位对比有一个是1的，结果为1，其余为0
print("Line 3 - Value of c is ", c)

# 按位取反运算符
c = ~a;     # -61 = 1100 0011   按照位指全部取反，原值为1则结果为0，原值为0则结果为1
print("Line 4 - Value of c is ", c)
print(bin(c))

# 左移运算符
c = a << 2;  # 240 = 1111 0000  按位向左移动2位
print("Line 5 - Value of c is ", c)

# 右移运算符
c = a >> 2;  # 15 = 0000 1111   按位向右移动2位
print("Line 6 - Value of c is ", c)
